<?php

namespace app\index\controller;

use think\Controller;

class Common extends Controller
{
    public function __construct()
    {
        parent::__construct();
        //获取顶级分类数据
        $cateDate = db('category')->where('pid',0)->limit(4)->select();
        $this->assign('cateData',$cateDate);
        //获取所有分类数据
        $cateData2 = db('category')->select();
        $this->assign('cateData2',$cateData2);
        //获取所有标签
        $tagData = db('tag')->select();
        $this->assign('tagData',$tagData);
        //获取最新的两篇文章
        $articleData2 = db('article')->order('sendtime desc')->limit(1)->select();
        $this->assign('articleData2',$articleData2[0]);
        //获取友情链接
        $linkData = db('link')->select();
        $this->assign('linkData',$linkData);
    }
}
